<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="!crud.props.searchToggle">
        <el-form size="small" label-width="70px" v-formkey="{query:toQuery}">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="是否显示零库存" label-width="120px">
                <el-select
                  v-model="query.isShowZeroStock"
                  class="filter-item"
                  clearable
                  placeholder="请选择"
                  size="small"
                  style="width: 100%"
                  @change="crud.toQuery"
                >
                  <el-option
                    v-for="item in dict.common_yes_or_no"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="是否显示零出入库数量" label-width="150px">
                <el-select
                  v-model="query.isShowZeroInOutDetail"
                  class="filter-item"
                  clearable
                  placeholder="请选择"
                  size="small"
                  style="width: 100%"
                  @change="storage"
                >
                  <el-option
                    v-for="item in dict.common_yes_or_no"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="批次">
                <el-input v-model="query.batchNo"></el-input>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="仓库">
                <!--                <zSelect :value.sync="query.warehouseIds"  url="api/dropDown/basWarehouseList" />-->
                <table-select
                  :tableColumns="[
                    { prop: 'code', label: '编码', width: '100' },
                    { prop: 'name', label: '名称', width: '300' },
                  ]"
                  :value.sync="query.warehouseIds"
                  placeholder="请选择仓库"
                  url="/api/dropDown/basWarehouseList"
                ></table-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="10" style="text-align: center">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="库位">
                <!--                <zSelect :value.sync="query.storehouseIds"   url="api/dropDown/basStorehouseList" />-->
                <table-select
                  :tableColumns="[
                    { prop: 'code', label: '编码', width: '100' },
                    { prop: 'name', label: '名称', width: '300' },
                  ]"
                  :value.sync="query.storehouseIds"
                  placeholder="请选择库位"
                  url="/api/dropDown/basStorehouseList"
                ></table-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="商品">
                <table-select
                  :tableColumns="[
                    { prop: 'goodsCode', label: '商品编码', width: '100' },
                    { prop: 'goodsName', label: '商品名称', width: '500' },
                  ]"
                  label-key="goodsName"
                  value-key="goodsId"
                  :value.sync="query.goodsIds"
                  placeholder="请选择商品"
                  url="/api/dropDown/basGoodsListForAdd"
                  :width="700"
                ></table-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="商品品牌">
                <!--                <zSelect :value.sync="goodsBrandIds" multiple   url="api/dropDown/basGoodsBrandList"  style="width:  100%"/>-->
                <table-select
                  :tableColumns="[
                    { prop: 'code', label: '编码', width: '100' },
                    { prop: 'name', label: '名称', width: '300' },
                  ]"
                  :value.sync="query.goodsBrandIds"
                  placeholder="请选择品牌"
                  url="/api/dropDown/basGoodsBrandList"
                ></table-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="商品分类">
                <treeselect
                  v-model="goodsTypeIds"
                  :options="typeList"
                  placeholder="商品分类"
                  style="width: 100%"
                  :normalizer="normalizer"
                  multiple
                  @select="getgoodsType"
                />
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="商贸公司">
                <!--                <zSelect :value.sync="customerIds" multiple :params="{type:2}"  url="api/dropDown/basCustomerList"  style="width:  100%"/>-->
                <table-select
                  :tableColumns="[
                    { prop: 'code', label: '编码', width: '100' },
                    { prop: 'name', label: '名称', width: '300' },
                  ]"
                  :value.sync="query.customerIds"
                  placeholder="请选择公司"
                  :params="{ type: 2 }"
                  url="/api/dropDown/basCustomerList"
                ></table-select>
              </el-form-item>
            </el-col>
            <!--            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">-->
            <!--              <el-form-item label="商品品牌">-->
            <!--                <zSelect :value.sync="goodsBrandIds" multiple   url="api/dropDown/basGoodsBrandList"  style="width:  100%"/>-->
            <!--              </el-form-item>-->
            <!--            </el-col>-->
            <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
              <el-form-item label="小计列">
                <el-checkbox-group v-model="groupColumn" @change="getChange">
                  <el-checkbox
                    v-for="item in groupColumnList"
                    :disabled="item.value == 'goodsId'"
                    :label="item.value"
                    :key="item.value"
                    :value="item.value"
                    >{{ item.label }}</el-checkbox
                  >
                </el-checkbox-group>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <span>
                <el-button
                  class="filter-item"
                  size="mini"
                  type="primary"
                  @click="crud.toQuery"
                  >搜索</el-button
                >
                <el-button
                  class="filter-item"
                  plain
                  size="mini"
                  type="primary"
                  @click="resetQuery"
                  >重置</el-button
                >
              </span>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <crudOperation :permission="permission">
        <el-button
          type="primary"
          slot="right"
          class="filter-item"
          size="mini"
          @click="adjust()"
          v-permission="permission.adjust"
          :disabled="crud.selections.length !== 1"
        >
          调整库存
        </el-button>
        <el-button
          type="primary"
          slot="right"
          class="filter-item"
          size="mini"
          v-if="showUpdatePriceBtn"
          @click="updatePrice()"
          v-permission="permission.adjust"
          :disabled="crud.selections.length !== 1"
        >
          修改成本
        </el-button>
        <el-button
          type="primary"
          slot="right"
          class="filter-item"
          size="mini"
          v-if="showUpdatePriceBtn"
          @click="queryUpdatePrice"
          v-permission="permission.adjust"
          :disabled="crud.selections.length !== 1"
        >
          成本修改记录
        </el-button>
      </crudOperation>
      <vue-context-menu
        :contextMenuData="contextMenuData"
        @tableConfig="tableConfig"
        @deletedata="deletedata"
      ></vue-context-menu>

      <el-dialog title="表格配置" :visible.sync="tableConfigShow" width="60%">
        <j-table-column-config
          :columns.sync="crud.header"
          @tabSave="tabSave"
          @pit="pit"
        />
      </el-dialog>
      <j-dialog
        title="待发明细"
        v-show="isWaitSend"
        :visible.sync="isWaitSend"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table1"
            stripe
            border
            :data="waitSendList"
            size="small"
            style="width: 100%"
            height="500"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="customerName" label="往来单位名称" />
            <el-table-column prop="orderCode" label="订单编号" />
            <el-table-column prop="orderType" label="单据类型">
              <template slot-scope="{ row }">
                {{ row.orderType == 1 ? "销售订单" : "采购退货单" }}
              </template>
            </el-table-column>
            <el-table-column prop="stockOrderCode" label="库存订单编码" />
            <el-table-column prop="goodsCount" label="数量" />
            <el-table-column prop="boxNum" label="箱数" />
            <el-table-column prop="mainNum" label="零数" />
          </el-table>
          <el-pagination
            :current-page="waitSendQuery.page"
            :page-size="waitSendQuery.size"
            layout="prev, pager, next"
            :total="waitSendQuery.total"
            :pager-count="5"
            @current-change="currentcurrent"
          />
        </div>
      </j-dialog>
      <div class="currnetImg">
        <img :src="currentImageUrl" />
      </div>
      <j-dialog is-mask title="调整成本价" style="width: 500px" :visible.sync="showSelectWareHouse">
<!--        <el-form  label-width="80px" size="small">-->
<!--          <el-form-item label="检查仓库" >-->
<!--            <zSelect :value.sync="selectWareHouse.id" @change="selectWareHouse = $event" :showName="selectWareHouse.name" url="api/dropDown/basWarehouseList"/>-->
<!--          </el-form-item>-->
<!--        </el-form>-->
        <el-form :rules="uwsp" ref="ruleForm" :model="updateWareStockPriceForm">
          <el-form-item label="开始日期" prop="startDate" >
            <el-date-picker
              v-model="updateWareStockPriceForm.startDate"
              type="date"
              size="small"
              style="width: 100%;"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
          <el-form-item label="结束日期" prop="endDate">
            <el-date-picker
              v-model="updateWareStockPriceForm.endDate"
              type="date"
              size="small"
              class="date"
              style="width: 100%;"
              value-format="yyyy-MM-dd"
            />
          </el-form-item>
          <el-form-item label="含税价" prop="costTaxPrice">
            <el-input v-model="updateWareStockPriceForm.costTaxPrice"/>
          </el-form-item>
          <div class="dialog-footer flex flex-reverse">
            <el-button @click="showSelectWareHouse = false">取 消</el-button>
            <el-button type="primary" @click="submitPrice">确 定</el-button>
          </div>
        </el-form>
      </j-dialog>
      <j-dialog
        title="配送在途明细"
        v-show="loadOnWay"
        :visible.sync="loadOnWay"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table2"
            stripe
            border
            :data="loadOnWayList"
            size="small"
            style="width: 100%"
            height="300"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="busDate" label="业务日期" />
            <!--            <el-table-column  prop="loadId" label="配送单id"/>-->
            <el-table-column prop="loadCode" label="配送单号" />
            <!--            <el-table-column  prop="carId" label="车辆id"/>-->
            <el-table-column prop="carLicense" label="车牌号" />
            <!--            <el-table-column  prop="driverUserId" label="驾驶员id"/>-->
            <el-table-column prop="driverUserName" label="驾驶员名称" />
            <!--            <el-table-column  prop="followUserIds" label="跟车id"/>-->
            <el-table-column prop="followUserName" label="跟车名称" />
            <!--            <el-table-column  prop="salesOrderId" label="销售单id"/>-->
            <el-table-column prop="salesOrderCode" label="销售单号" />
            <el-table-column prop="acceptGoodsCount" label="验收数量" />
            <el-table-column prop="acceptBoxNum" label="验收箱数" />
            <el-table-column prop="acceptMainNum" label="验收零数" />
          </el-table>
          <el-pagination
            :current-page="loadOnWayQuery.page"
            :page-size="loadOnWayQuery.size"
            layout="prev, pager, next "
            :total="loadOnWayQuery.total"
            :pager-count="5"
            @current-change="currentcurrent1"
          />
        </div>
      </j-dialog>
      <j-dialog
        title="修改记录"
        :visible.sync="showRecord"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table2"
            stripe
            border
            :data="updateList"
            size="small"
            style="width: 100%"
            height="300"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="startDate" label="开始日期" />
            <el-table-column prop="endDate" label="结束日期" />
            <el-table-column prop="costTaxPrice" label="修改成本" />
          </el-table>
          <el-pagination
            :current-page="loadOnWayQuery.page"
            :page-size="loadOnWayQuery.size"
            layout="prev, pager, next "
            :total="loadOnWayQuery.total"
            :pager-count="5"
            @current-change="currentcurrent1"
          />
        </div>
      </j-dialog>
      <j-dialog
        title="在途量明细"
        v-show="isOnWay"
        :visible.sync="isOnWay"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table3"
            stripe
            border
            :data="onWayList"
            size="small"
            style="width: 100%"
            height="500"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="customerName" label="往来单位名称" />
            <el-table-column prop="orderCode" label="订单编号" />
            <el-table-column prop="orderType" label="单据类型">
              <template slot-scope="{ row }">
                {{ row.orderType == 1 ? "销售退货单" : (row.orderType == 2 ? "采购入库单" : "调拨单") }}
              </template>
            </el-table-column>
            <el-table-column prop="stockOrderCode" label="库存订单编码" />
            <el-table-column prop="goodsCount" label="数量" />
            <el-table-column prop="boxNum" label="箱数" />
            <el-table-column prop="mainNum" label="零数" />
          </el-table>
          <el-pagination
            :current-page="onWayQuery.page"
            :page-size="onWayQuery.size"
            layout="prev, pager, next"
            :total="onWayQuery.total"
            :pager-count="5"
            @current-change="currentcurrent2"
          />
        </div>
      </j-dialog>
      <j-dialog
        title="加锁可用量明细"
        v-show="isLockUsable"
        :visible.sync="isLockUsable"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table4"
            stripe
            border
            :data="lockUsableList"
            size="small"
            style="width: 100%"
            height="500"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="customerName" label="往来单位名称" />
            <el-table-column prop="orderCode" label="订单编号" />
            <el-table-column prop="orderType" label="单据类型">
              <template slot-scope="{ row }">
                {{ row.orderType == 1 ? "销售订单" : "" }}
              </template>
            </el-table-column>
            <el-table-column prop="lockStockDate" label="加锁日期" />
            <el-table-column prop="lockStockUserName" label="加锁人员" />
            <el-table-column prop="goodsCount" label="数量" />
            <el-table-column prop="boxNum" label="箱数" />
            <el-table-column prop="mainNum" label="零数" />
          </el-table>
          <el-pagination
            :current-page="lockUsableQuery.page"
            :page-size="lockUsableQuery.size"
            layout="prev, pager, next"
            :total="lockUsableQuery.total"
            :pager-count="5"
            @current-change="currentcurrent3"
          />
        </div>
      </j-dialog>
      <j-dialog
        title="拣货量明细"
        v-show="isPick"
        :visible.sync="isPick"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table5"
            stripe
            border
            :data="pickList"
            size="small"
            style="width: 100%"
            height="500"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="customerName" label="往来单位名称" />
            <el-table-column prop="orderCode" label="订单编号" />
            <el-table-column prop="orderType" label="单据类型">
              <template slot-scope="{ row }">
                {{ row.orderType == 1 ? "销售订单" : "" }}
              </template>
            </el-table-column>
            <el-table-column prop="stockOrderCode" label="库存订单编码" />
            <el-table-column prop="pickEndTime" label="拣货完成时间" />
            <el-table-column prop="pickUserName" label="拣货人员" />
            <el-table-column prop="goodsCount" label="数量" />
            <el-table-column prop="boxNum" label="箱数" />
            <el-table-column prop="mainNum" label="零数" />
          </el-table>
          <el-pagination
            :current-page="pickQuery.page"
            :page-size="pickQuery.size"
            layout="prev, pager, next"
            :total="pickQuery.total"
            :pager-count="5"
            @current-change="currentcurrent4"
          />
        </div>
      </j-dialog>
      <j-dialog
        title="调拨待发量明细"
        v-show="isAllotOut"
        :visible.sync="isAllotOut"
        style="width: 80%"
        isMask
      >
        <div>
          <el-table
            ref="table6"
            stripe
            border
            :data="allotOutList"
            size="small"
            style="width: 100%"
            height="500"
            show-summary
            :summary-method="sendSumRow"
          >
            <el-table-column type="selection" width="60" />
            <el-table-column type="index" width="60" label="序号" />
            <el-table-column prop="orderCode" label="订单编号" />
            <el-table-column prop="orderType" label="单据类型">
              <template slot-scope="{ row }">
                {{ row.orderType == 3 ? "调拨单" : "" }}
              </template>
            </el-table-column>
            <el-table-column prop="goodsCount" label="数量" />
            <el-table-column prop="boxNum" label="箱数" />
            <el-table-column prop="mainNum" label="零数" />
          </el-table>
          <el-pagination
            :current-page="allotOutQuery.page"
            :page-size="allotOutQuery.size"
            layout="prev, pager, next"
            :total="allotOutQuery.total"
            :pager-count="5"
            @current-change="currentcurrent5"
          />
        </div>
      </j-dialog>
      <!--表单组件-->
      <el-dialog
        :close-on-click-modal="false"
        :before-close="crud.cancelCU"
        :visible.sync="crud.status.cu > 0"
        :title="crud.status.title"
      >
        <el-form
          ref="form"
          :model="form"
          :rules="rules"
          size="small"
          label-width="80px"
        >
          <div class="flex flex-row">
            <el-form-item label="出入库类型">
              <el-select
                v-model="form.type"
                clearable
                class="edit-input"
                placeholder="入库/出库"
              >
                <el-option
                  v-for="(item, index) in options"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                />
              </el-select>
            </el-form-item>
            <el-form-item
              :render-header="crud.renderHeader"
              v-if="columns.visible('boxUnitId')"
              prop="boxUnitId"
              label="辅数量"
            >
              <!-- <el-input v-model="form.boxUnitId"  /> -->
              <el-input
                @change="changGoodsCount(form, 'boxNum')"
                maxlength="12"
                v-model="form.boxNum"
                style="width: 50%; float: left"
              >
                <div
                  slot="suffix"
                  style="height: 100%; font-size: 15px; color: black"
                  class="flex a-item j-content"
                >
                  {{ form.boxUnitName }}
                </div>
              </el-input>
              <el-input
                maxlength="12"
                v-model="form.mainNum"
                @change="changGoodsCount(form, 'mainNum')"
                style="width: 50%; float: left"
              >
                <div
                  slot="suffix"
                  style="height: 100%; font-size: 15px; color: black"
                  class="flex a-item j-content"
                >
                  {{ form.mainUnitName }}
                </div>
                %
              </el-input>
            </el-form-item>
            <el-form-item label="仓库">
              <zSelect  :value.sync="form.warehouseId"  url="api/dropDown/basWarehouseList" />

            </el-form-item>
            <el-form-item label="库区" >
              <zSelect  :value.sync="form.locationId"  url="/api/dropDown/basLocationList" style="width:  100%;"/>
            </el-form-item>

            <el-form-item label="库位" >
              <zSelect  :value.sync="form.storehouseId"  url="/api/dropDown/basStorehouseList" style="width:  100%;"/>
            </el-form-item>

            <el-form-item label="单价">
              <el-input v-model="form.taxPrice" />
            </el-form-item>
            <el-form-item label="箱价">
              <el-input v-model="form.taxBoxPrice" />
            </el-form-item>
            <el-form-item label="备注">
              <el-input v-model="form.remark" />
            </el-form-item>
          </div>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button
            :loading="crud.cu === 2"
            type="primary"
            @click="submitAdjustStock"
            >确认</el-button
          >
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table
        ref="table"
        stripe
        border
        height="700"
        v-loading="crud.loading"
        :data="crud.data"
        size="small"
        @sort-change="(row) => sortTab(row)"
        v-if="isShowTable"
        @header-dragend="changeColWidth"
        @contextmenu.native="showMenu"
        style="width: 100%"
        show-summary
        :summary-method="crud.sumRow"
        @selection-change="crud.selectionChangeHandler"
        @row-dblclick="crud.toDetailPlus('wareStockExistDetail', $event.id)"
      >
        <el-table-column
          :render-header="crud.renderHeader"
          type="selection"
          width="60"
        />
        <el-table-column
          :render-header="crud.renderHeader"
          type="index"
          width="60"
          label="序号"
        />
        <el-table-column
          v-if="item.visible"
          v-for="(item, index) in crud.header"
          :key="`col_${index}`"
          :prop="item.prop"
          :label="columnLabel(item)"
          :width="item.width + 'px'"
          :data-porp="item.prop"
          @contextmenu.native="showMenu"
          @header-dragend="changeColWidth"
          :sortable="item.sortable ? 'custom' : false"
          :sort-orders="['descending', 'ascending', null]"
          sort-change="sort"
        >
          <!-- 自定义渲染模版 -->
          <template slot-scope="scope">
            <!-- 当列key为 sort 时，渲染一个手柄icon -->
            <template>
              <span
                v-if="item.type == 1"
                :class="{ blue: item.prop === 'waitSendNum' }"
                style="margin-left: 10px"
              >
                {{ scope.row[`${item.prop}`] }}
              </span>
              <span v-else-if="item.type == 2" style="margin-left: 10px">{{
                parseTime(scope.row[`${item.prop}`])
              }}</span>
              <span v-else-if="item.type == 3" style="margin-left: 10px">{{
                getDict(
                  `this.dict.label.${item.dictionary}["${
                    scope.row[item.prop]
                  }"]`
                )
              }}</span>
              <span v-else-if="item.type == 4" style="margin-left: 10px">
                <span v-if="item.prop == 'existBoxNum'">
                  {{ scope.row.existBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.existMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span v-else-if="item.prop == 'existBoxCount'">
                  {{ scope.row.existBoxCount }}{{ scope.row.boxUnitName }}
                </span>
                <span v-else-if="item.prop == 'expectUsableNum'">
                  {{ scope.row.expectUsableBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.expectUsableMainNum
                  }}{{ scope.row.mainUnitName }}
                </span>
                <span v-else-if="item.prop == 'expectUsableBoxCount'">
                  {{ scope.row.expectUsableBoxCount
                  }}{{ scope.row.boxUnitName }}
                </span>
                <span v-else-if="item.prop == 'usableBoxNum'">
                  {{ scope.row.usableBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.usableMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span v-else-if="item.prop == 'usableBoxCount'">
                  {{ scope.row.usableBoxCount }}{{ scope.row.boxUnitName }}
                </span>
                <span v-else-if="item.prop == 'onWayBoxNum'"
                  class="blue"
                  @click="openOnWay(scope.row.id)"
                >
                  {{ scope.row.onWayBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.onWayMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span v-else-if="item.prop == 'onWayBoxCount'">
                  {{ scope.row.onWayBoxCount }}{{ scope.row.boxUnitName }}
                </span>
                <span
                  v-else-if="item.prop == 'waitSendBoxNum'"
                  class="blue"
                  @click="openWaitSend(scope.row.id)"
                >
                  {{ scope.row.waitSendBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.waitSendMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span v-else-if="item.prop == 'waitSendBoxCount'">
                  {{ scope.row.waitSendBoxCount }}{{ scope.row.boxUnitName }}
                </span>
                <span v-else-if="item.prop == 'allotOutBoxCount'">
                  {{ scope.row.allotOutBoxCount }}{{ scope.row.boxUnitName }}
                </span>
                <span v-else-if="item.prop == 'allotInBoxNum'">
                  {{ scope.row.allotInBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.allotInMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span v-else-if="item.prop == 'allotInBoxCount'">
                  {{ scope.row.allotInBoxCount }}{{ scope.row.boxUnitName }}
                </span>
                <span
                  v-else-if="item.prop == 'waitSendNum'"
                  class="blue"
                  @click="openWaitSend(scope.row.id)"
                >
                  {{ scope.row.waitSendNum }}
                </span>
                <span
                  v-else-if="item.prop == 'loadOnWayNum'"
                  class="blue"
                  @click="openLoadOnWay(scope.row.id)"
                >
                  {{ scope.row.loadOnWayNum || 0 }}
                </span>
                <span v-else-if="item.prop == 'loadOnWayBoxCount'">
                  {{ scope.row.loadOnWayBoxCount || 0
                  }}{{ scope.row.boxUnitName }}
                </span>
                <span
                  v-else-if="item.prop == 'loadOnWayBoxNum'"
                  class="blue"
                  @click="openLoadOnWay(scope.row.id)"
                >
                  {{ scope.row.loadOnWayBoxNum || 0 }}{{ scope.row.boxUnitName
                  }}{{ scope.row.loadOnWayMainNum || 0
                  }}{{ scope.row.mainUnitName }}
                </span>
                <span  v-else-if="item.prop == 'image'">
                    <el-image
                      v-if="scope.row.image"
                      style="width: 30px;height: 30px"
                      :src="scope.row.image"
                      :preview-src-list="[scope.row.image]" />
                </span>
                <span
                  v-else-if="item.prop == 'onWayNum'"
                  class="blue"
                  @click="openOnWay(scope.row.id)"
                >
                  {{ scope.row.onWayNum }}
                </span>
                <span
                  v-else-if="item.prop == 'lockUsableNum'"
                  class="blue"
                  @click="openLockUsable(scope.row.id)"
                >
                  {{ scope.row.lockUsableNum }}
                </span>
                <span v-else-if="item.prop == 'lockUsableBoxNum'"
                      class="blue"
                      @click="openLockUsable(scope.row.id)"
                >
                  {{ scope.row.lockUsableBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.lockUsableMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span
                  v-else-if="item.prop == 'pickNum'"
                  class="blue"
                  @click="openPick(scope.row.id)"
                >
                  {{ scope.row.pickNum }}
                </span>
                <span v-else-if="item.prop == 'pickBoxNum'"
                      class="blue"
                      @click="openPick(scope.row.id)"
                >
                  {{ scope.row.pickBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.pickMainNum }}{{ scope.row.mainUnitName }}
                </span>
                <span
                  v-else-if="item.prop == 'allotOutNum'"
                  class="blue"
                  @click="openAllotOut(scope.row.id)"
                >
                  {{ scope.row.allotOutNum }}
                </span>
                <span v-else-if="item.prop == 'allotOutBoxNum'"
                      class="blue"
                      @click="openAllotOut(scope.row.id)"
                >
                  {{ scope.row.allotOutBoxNum }}{{ scope.row.boxUnitName
                  }}{{ scope.row.allotOutMainNum }}{{ scope.row.mainUnitName }}
                </span>
              </span>
            </template>
          </template>
        </el-table-column>
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseName')" prop="warehouseName" label="仓库" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('locationName')" prop="locationName" label="库区" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('storehouseName')" prop="storehouseName" label="库位" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('goodsCode')" prop="goodsCode" label="商品编码" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('goodsName')" prop="goodsName" label="商品名称" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('helpSign')" prop="helpSign" label="助记符" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('barcode')" prop="barcode" label="条形码" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('model')" prop="model" label="规格型号" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('goodsBrandName')" prop="goodsBrandName" label="品牌" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('goodsTypeName')" prop="goodsTypeName" label="商品分类" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('costTaxPrice')" prop="costTaxPrice" label="含税成本价" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('costNoTaxPrice')" prop="costNoTaxPrice" label="未税成本价" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('existNum')" prop="existNum" label="现存量" />-->
        <!--&lt;!&ndash;        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('initNum')" prop="initNum" label="初始数量" />&ndash;&gt;-->
        <!--&lt;!&ndash;        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('inNum')" prop="inNum" label="入库数量" />&ndash;&gt;-->
        <!--&lt;!&ndash;        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('endNum')" prop="endNum" label="剩余数量" />&ndash;&gt;-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('costTaxAmount')" prop="costTaxAmount" label="含税成本金额" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('costNoTaxAmount')" prop="costNoTaxAmount" label="未税成本金额"  />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('pickNum')" prop="pickNum" label="拣货数量" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('usableNum')" prop="usableNum" label="可用量" />-->
        <!--&lt;!&ndash;        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('pickNum')" prop="pickNum" label="库存记录" />&ndash;&gt;-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('waitSendNum')" prop="waitSendNum" label="待发量" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('allotOutNum')" prop="allotOutNum" label="调拨待发量" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('allotInNum')" prop="allotInNum" label="调拨待入量" />-->

        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('onWayNum')" prop="onWayNum" label="在途量" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('expectUsableNum')" prop="expectUsableNum" label="预计可用量" />-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('producedDate')" prop="producedDate" label="生产日期">-->
        <!--          <template slot-scope="scope">-->
        <!--            <span>{{ parseTime(scope.row.producedDate) }}</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('deadlineDate')" prop="deadlineDate" label="截止日期">-->
        <!--          <template slot-scope="scope">-->
        <!--            <span>{{ parseTime(scope.row.deadlineDate) }}</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->

        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createTime')" prop="createTime" label="添加时间">-->
        <!--          <template slot-scope="scope">-->
        <!--            <span>{{ parseTime(scope.row.createTime) }}</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateTime')" prop="updateTime" label="修改时间">-->
        <!--          <template slot-scope="scope">-->
        <!--            <span>{{ parseTime(scope.row.updateTime) }}</span>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudWareStockExist, { getWareStockUpdateCostPrice, wareStockUpdateCostPrice } from '@/api/erp/wareStockExist'
import CRUD, { presenter, header, form, crud } from "@crud/crud";
import rrOperation from "@crud/RR.operation";
import crudOperation from "@crud/CRUD.operation";
import udOperation from "@crud/UD.operation";
import pagination from "@crud/Pagination";

import { getTypeList } from "@/api/erp/basGoodsType";
import Treeselect from "@riophae/vue-treeselect";
import { tablemixins } from "@/mixins/tablemixins";
import jTableColumnConfig from "@/components/jTableColumnConfig/jTableColumnConfig";
import { publicListKey } from "@/utils/key";
import JDialog from "@/components/jDialog/jDialog";
import { getWareStockExistWaitSendNumDetailInfo,
  getWareStockExistOnWayNumDetailInfo,
  getWareStockExistLockUsableNumDetailInfo,
  getWareStockExistPickNumDetailInfo,
  getWareStockExistAllotOutNumDetailInfo
} from "@/api/erp/wareStockExist";
import { getLoadOnWayInfo } from "@/api/erp/wareStockExist";

// crud交由presenter持有
const defaultCrud = CRUD({
  title: "库存记录",
  name: "wareStockExist",
  url: "api/wareStockExist",
  sort: "",
  query: {
    groupColumn: "goodsId",
  },
  optShow: {
    add: false,
    edit: false,
    del: false,
    download: true,
    downloadDetail: true,
    leadingIn: true,
    enable: false,
    disable: false,
    pass: false,
    reject: false,
  },
  crudMethod: { ...crudWareStockExist },
});
const defaultForm = {
  id: null,
  goodsId: null,
  warehouseId: null,
  locationId: null,
  storehouseId: null,
  batchNo: null,
  producedDate: null,
  deadlineDate: null,
  existNum: null,
  usableNum: null,
  waitSendNum: null,
  allotInNum: null,
  allotOutNum: null,
  onWayNum: null,
  lockUsableNum: null,
  expectUsableNum: null,
  pickNum: null,
  version: null,
  costTaxPrice: null,
  costNoTaxPrice: null,
  costTaxAmount: null,
  costNoTaxAmount: null,
  createTime: null,
  updateTime: null,
  loadOnWayBoxCount: null,
};
export default {
  name: "WareStockExist",
  components: {
    JDialog,
    pagination,
    crudOperation,
    rrOperation,
    udOperation,
    Treeselect,
    jTableColumnConfig,
  },
  mixins: [
    presenter(defaultCrud),
    header(),
    form(defaultForm),
    crud(),
    tablemixins,
    publicListKey,
  ],
  dicts: ["common_yes_or_no"],
  data() {
    return {
      options: [
        {
          value: "2",
          label: "出库",
        },
        {
          value: "1",
          label: "入库",
        },
      ],
      uwsp:{
        startDate: [
          { required: true, message: '请选择开始日期', trigger: 'change' }
        ],
        endDate: [
          { required: true, message: '请选择结束日期', trigger: 'change' }
        ],
        costTaxPrice: [
          { required: true, message: '请输入成本税价', trigger: 'change' }
        ],
      },
      showSelectWareHouse:false,
      selectWareHouse:{id:0,name:''},
      permission: {
        add: ["admin", "wareStockExist:add"],
        edit: ["admin", "wareStockExist:edit"],
        del: ["admin", "wareStockExist:del"],
        import: ["admin", "wareStockExist:import"],
        export: ["admin", "wareStockExist:export"],
        copy: ["admin", "wareStockExist:copy"],
        upload: ["admin", "wareStockExist:upload"],
        download: ["admin", "wareStockExist:download"],
      },
      goodsBrandIds: [],
      customerIds: [],
      groupColumn: ["goodsId"],
      warehouseId: null,
      storehouseId: null,
      goodsId: null,
      goodsTypeIds: [],
      goodsBrandId: null,
      goodsTypeId: null,
      customerId: null,
      multiple: true,
      isWaitSend: false,
      isOnWay: false,
      isLockUsable: false,
      isPick: false,
      isAllotOut: false,
      url:'',
      loadOnWay: false,
      currentImage:{
        path:'',
        x:0,
        y:0
      },
      groupColumnList: [
        {
          label: "商品",
          value: "goodsId",
        },
        {
          label: "仓库",
          value: "warehouseId",
        },
        {
          label: "批次",
          value: "batchNo",
        },
        {
          label: "库位",
          value: "storehouseId",
        },
        {
          label: "库区",
          value: "locationId",
        },
      ],
      typeList: [],
      rules: {
        goodsId: [
          { required: true, message: "商品id不能为空", trigger: "blur" },
        ],
      },
      waitSendQuery: {
        page: 1,
        size: 999,
        id: 0,
        total: 0,
      },
      onWayQuery: {
        page: 1,
        size: 999,
        id: 0,
        total: 0,
      },
      lockUsableQuery: {
        page: 1,
        size: 999,
        ids: '',
        total: 0,
      },
      pickQuery: {
        page: 1,
        size: 999,
        ids: '',
        total: 0,
      },
      allotOutQuery: {
        page: 1,
        size: 999,
        ids: '',
        total: 0,
      },
      showRecord:false,
      loadOnWayQuery: {
        page: 1,
        size: 10,
        id: 0,
        total: 0,
      },
      updateList:[],
      showUpdatePriceBtn:false,
      waitSendList: [],
      onWayList: [],
      lockUsableList: [],
      pickList: [],
      allotOutList: [],
      loadOnWayList: [],
      updateWareStockPriceForm:{
        startDate:'',
        endDate:'',
        existId:'',
        costTaxPrice:0
      }
    };
  },
  watch: {
    customerIds: {
      handler(n, o) {
        this.query.customerIds = n.join(",");
      },
      deep: true,
    },
    goodsBrandIds: {
      handler(n, o) {
        this.query.goodsBrandIds = n.join(",");
      },
      deep: true,
    },
    goodsTypeIds(n) {
      if (!n.length) {
        this.query.goodsTypeIds = null;
      }
    },
  },
  created() {
    this.getTypeList();
  },

  updated() {
    this.$nextTick(() => {
      this.$refs.table.doLayout();
      this.$refs.table1.doLayout();
      this.$refs.table2.doLayout();
      this.$refs.table3.doLayout();
      this.$refs.table4.doLayout();
      this.$refs.table5.doLayout();
      this.$refs.table6.doLayout();
    });
  },
  methods: {
    adjust() {
      const {
        goodsId,
        warehouseId,
        locationId,
        storehouseId,
        costTaxPrice,
        boxUnitName,
        mainUnitName,
        boxUnitCount,
      } = this.crud.selections[0];
      this.form = {
        goodsId,
        warehouseId,
        locationId,
        storehouseId,
        taxPrice: costTaxPrice,
        boxUnitName,
        mainUnitName,
        boxUnitCount,
      };
      this.form.taxBoxPrice = costTaxPrice * boxUnitCount;
      this.form.warehouseId='';
      this.form.storehouseId='';
      this.form.locationId='';
      this.$set(form, "boxNum", 0);
      this.$set(form, "mainNum", 0);
      this.crud.status.edit = 1;
    },
    changGoodsCount(form, type) {
      if (type === "mainNum") {
        const boxCount =
          ((Number(form.mainNum) || 0) / Number(form.boxUnitCount)) >> 0;
        const mainCount = Number(form.mainNum) % Number(form.boxUnitCount);
        form.boxNum = Number(form.boxNum) + boxCount;
        form.mainNum = mainCount;
      }
      form.goodsCount =
        (Number(form.boxNum) || 0) * Number(form.boxUnitCount) +
        (Number(form.mainNum) || 0);
    },
    showImage(url){
      this.currentImageUrl = url
    },
    hideImage(e){
      console.log('鼠标划出')
    },
    getChange() {
      if (this.groupColumn) {
        this.query.groupColumn = this.groupColumn.join(",");
      }
    },
    submitPrice() {
      if(this.updateWareStockPriceForm.endDate < this.updateWareStockPriceForm.startDate){
        this.$message.error('结束日期不能小于开始日期')
        return
      }
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          wareStockUpdateCostPrice(this.updateWareStockPriceForm).then(res=>{
              if(res.status === 200){
                this.$message.success('修改成功')
                this.showSelectWareHouse = false
                this.crud.refresh()
              }
          })

        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    // 获取数据前设置好接口地址
    [CRUD.HOOK.afterRefresh]() {
      this.crud.data.forEach(item=>{
        if (item.imageUrl && item.imageUrl!=='null') this.$set(item,'image',JSON.parse(item.imageUrl)[0].path)
      })
      if(this.groupColumn.includes('goodsId') && this.groupColumn.includes('warehouseId')){
        this.showUpdatePriceBtn = true
      }else {
        this.showUpdatePriceBtn = false
      }
      return true;
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {},
    getTypeList() {
      getTypeList({ page: 0, size: 999 }).then((res) => {
        this.typeList = res;
      });
    },
    currentcurrent(val) {
      // console.log(val);
      this.waitSendQuery.page = val;
      // console.log(this.waitSendQuery.page);
      this.getWaitSend();
    },
    async queryUpdatePrice(){
     const res =  await getWareStockUpdateCostPrice({existId:this.crud.selections[0].id})
     this.updateList = res.data.content
      //显示库存修改记录
      this.showRecord= true
    },
    updatePrice(){
      this.updateWareStockPriceForm.existId = this.crud.selections[0].id
      this.updateWareStockPriceForm.costTaxPrice = this.crud.selections[0].costTaxPrice

      this.showSelectWareHouse = true
    },
    currentcurrent1(val) {
      // console.log(val);
      this.loadOnWayQuery.page = val;
      // console.log(this.loadOnWayQuery.page);
      this.getLoadOnWaySend();
    },
    currentcurrent2(val) {
      this.onWayQuery.page = val;
      this.getOnWay();
    },
    currentcurrent3(val) {
      this.lockUsableQuery.page = val;
      this.getLockUsable();
    },
    currentcurrent4(val) {
      this.pickQuery.page = val;
      this.getPick();
    },
    currentcurrent5(val) {
      this.allotOutQuery.page = val;
      this.getAllotOut();
    },
    openWaitSend(id) {
      this.waitSendQuery.id = id;
      this.waitSendQuery.page = 1;
      this.getWaitSend();
      this.isWaitSend = true;
    },
    openOnWay(id) {
      this.onWayQuery.id = id;
      this.onWayQuery.page = 1;
      this.getOnWay();
      this.isOnWay = true;
    },
    openLockUsable(id) {
      this.lockUsableQuery.ids = id;
      this.lockUsableQuery.page = 1;
      this.getLockUsable();
      this.isLockUsable = true;
    },
    openPick(id) {
      this.pickQuery.id = id;
      this.pickQuery.page = 1;
      this.getPick();
      this.isPick = true;
    },
    openAllotOut(id) {
      this.allotOutQuery.id = id;
      this.allotOutQuery.page = 1;
      this.getAllotOut();
      this.isAllotOut = true;
    },
    openLoadOnWay(id) {
      this.loadOnWayQuery.id = id;
      this.loadOnWayQuery.page = 1;
      this.getLoadOnWaySend();
      this.loadOnWay = true;
    },
    sendSumRow(param) {
      const { columns, data } = param;
      const sums = [];
      const summaryList = [
        "boxCount",
        "taxAmount",
        "productCount",
        "totalGrossWeight",
        "totalNetWeight",
        "count",
        "noTaxAmount",
        "discountAmount",
        "acceptBoxCount",
        "acceptGoodsCount",
        "acceptTaxAmount",
        "acceptTax",
        "cancelAmount",
        "unCancelAmount",
        "goodsCount",
        "checkGoodsCount",
        "inAmount",
        "balanceAmount",
        "tax",
        "acceptBoxNum",
        "acceptMainNum",
        "acceptNoTaxAmount",
        "enterGoodsCount",
        "enterBoxCount",
        "enterBoxNum",
        "enterMainNum",
        "enterTaxAmount",
        "enterNoTaxAmount",
        "enterTax",
        "returnGoodsCount",
        "returnBoxCount",
        "returnBoxNum",
        "returnMainNum",
        "returnTaxAmount",
        "returnNoTaxAmount",
        "returnTax",
        "sendGoodsCount",
        "sendBoxCount",
        "sendBoxNum",
        "sendMainNum",
        "sendTaxAmount",
        "sendNoTaxAmount",
        "sendTax",
        "returnBottleBoxGoodsCount",
        "returnBottleBoxBoxCount",
        "returnBottleBoxBoxNum",
        "returnBottleBoxMainNum",
        "returnBottleBoxTaxAmount",
        "returnBottleBoxNoTaxAmount",
        "returnBottleBoxTax",
        "buyGoodsCount",
        "buyBoxCount",
        "buyBoxNum",
        "buyMainNum",
        "buyTaxAmount",
        "buyNoTaxAmount",
        "buyTax",
        "saleGoodsCount",
        "saleBoxCount",
        "saleBoxNum",
        "saleMainNum",
        "saleTaxAmount",
        "saleNoTaxAmount",
        "saleTax",
        "allotGoodsCount",
        "form.allotBoxCount",
        "allotBoxNum",
        "allotMainNum",
        "allotTaxAmount",
        "allotNoTaxAmount",
        "allotTax",
        "lossGoodsCount",
        "lossBoxCount",
        "lossBoxNum",
        "lossMainNum",
        "lossTaxAmount",
        "lossNoTaxAmount",
        "lossTax",
        "overGoodsCount",
        "overBoxCount",
        "overBoxNum",
        "overMainNum",
        "overTaxAmount",
        "overNoTaxAmount",
        "overTax",
        "allotBoxCount",
        "emptyBoxTaxAmount",
        "returnBoxTaxAmount",
        "receiveAmount",
        "boxNum",
        "mainNum",
        "loadOnWayNum",
        "loadOnWayBoxCount",
        "loadOnWayBoxNum",
        "onWayNum",
        "onWayBoxCount",
        "onWayBoxNum",
        "lockUsableNum",
        "lockUsableBoxCount",
        "lockUsableBoxNum",
        "pickNum",
        "pickBoxCount",
        "pickBoxNum",
        "allotOutNum",
        "allotOutBoxCount",
        "allotOutBoxNum",
        "costTaxAmount"
      ];
      columns.forEach((column, index) => {
        let selectSum = 0;
        if (index === 0) {
          sums[index] = (
            <p>
              选中合计
              <hr />
              合计
            </p>
          );
          column.colSpan = 2;
          return;
        }
        if (this.$refs.table1.selection.length > 0) {
          this.$refs.table1.selection.map((sel) => {
            for (const key in sel) {
              if (column.property === key) {
                if (summaryList.includes(key)) {
                  selectSum = (
                    parseFloat(sel[key]) + parseFloat(selectSum || 0)
                  ).toFixed(2);
                }
              }
            }
          });
        }
        if (this.$refs.table2.selection.length > 0) {
          this.$refs.table2.selection.map((sel) => {
            for (const key in sel) {
              if (column.property === key) {
                if (summaryList.includes(key)) {
                  selectSum = (
                    parseFloat(sel[key]) + parseFloat(selectSum || 0)
                  ).toFixed(2);
                }
              }
            }
          });
        }
        if (this.$refs.table3.selection.length > 0) {
          this.$refs.table3.selection.map((sel) => {
            for (const key in sel) {
              if (column.property === key) {
                if (summaryList.includes(key)) {
                  selectSum = (
                    parseFloat(sel[key]) + parseFloat(selectSum || 0)
                  ).toFixed(2);
                }
              }
            }
          });
        }
        if (this.$refs.table4.selection.length > 0) {
          this.$refs.table4.selection.map((sel) => {
            for (const key in sel) {
              if (column.property === key) {
                if (summaryList.includes(key)) {
                  selectSum = (
                    parseFloat(sel[key]) + parseFloat(selectSum || 0)
                  ).toFixed(2);
                }
              }
            }
          });
        }
        if (this.$refs.table5.selection.length > 0) {
          this.$refs.table5.selection.map((sel) => {
            for (const key in sel) {
              if (column.property === key) {
                if (summaryList.includes(key)) {
                  selectSum = (
                    parseFloat(sel[key]) + parseFloat(selectSum || 0)
                  ).toFixed(2);
                }
              }
            }
          });
        }
        if (summaryList.includes(column.property)) {
          // 指定哪一列合计 如果需要全部合计 去掉这个判断即可
          const values = data.map((item) => Number(item[column.property]));
          if (!values.every((value) => isNaN(value))) {
            const sum = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                const sum = prev + curr;
                return sum;
              } else {
                return prev;
              }
            }, 0);
            sums[index - 1] = (
              <p>
                {selectSum}
                <hr />
                {sum.toFixed(2)}
              </p>
            );
          } else {
            sums[index - 1] = "";
          }
        }
      });
      return sums;
    },
    getWaitSend() {
      getWareStockExistWaitSendNumDetailInfo(this.waitSendQuery).then((res) => {
        this.waitSendList = res.data.content;
        this.waitSendQuery.total = res.data.totalElements;
      });
    },
    getOnWay() {
      getWareStockExistOnWayNumDetailInfo(this.onWayQuery).then((res) => {
        this.onWayList = res.data.content;
        this.onWayQuery.total = res.data.totalElements;
      });
    },
    getLockUsable() {
      getWareStockExistLockUsableNumDetailInfo(this.lockUsableQuery).then((res) => {
        this.lockUsableList = res.data.content;
        this.lockUsableQuery.total = res.data.totalElements;
      });
    },
    getPick() {
      getWareStockExistPickNumDetailInfo(this.pickQuery).then((res) => {
        this.pickList = res.data.content;
        this.pickQuery.total = res.data.totalElements;
      });
    },
    getAllotOut() {
      getWareStockExistAllotOutNumDetailInfo(this.allotOutQuery).then((res) => {
        this.allotOutList = res.data.content;
        this.allotOutQuery.total = res.data.totalElements;
      });
    },
    submitAdjustStock() {
      crudWareStockExist.adjust(this.form).then((res) => {
        if (res.status === 200) {
          this.crud.status.edit = 0;
          this.$message.success(res.msg);
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    getLoadOnWaySend() {
      getLoadOnWayInfo(this.loadOnWayQuery).then((res) => {
        this.loadOnWayList = res.data.content;
        this.loadOnWayQuery.total = res.data.totalElements;
      });
    },

    normalizer(node) {
      //去掉children=[]的children属性
      if (node.children == null || node.children.length == 0) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.children,
      };
    },
    getgoodsType(node) {
      this.query.goodsTypeIds = this.getNode(
        node,
        this.query.goodsTypeIds ? this.query.goodsTypeIds : ""
      );
    },
    storage(val) {
      sessionStorage.setItem("isShowZeroInOutDetail", val);
      this.crud.toQuery();
    },
    getNode(node, str) {
      if (node.children) {
        for (let i = 0; i < node.children.length; i++) {
          str = this.getNode(node.children[i], str);
        }
      }
      return (str += node.id + ",");
    },
    resetQuery() {
      this.goodsTypeIds = [];
      this.crud.resetQuery();
    },
  },
};
</script>

<style scoped lang="scss">
.table-img {
  display: inline-block;
  text-align: center;
  background: #ccc;
  color: #fff;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  vertical-align: middle;
  width: 32px;
  height: 32px;
  line-height: 32px;
}
.blue {
  color: blue;
  cursor: pointer;
}
.flex {
  flex-wrap: wrap;
  ::v-deep.el-form-item--small {
    width: 275px;
  }
}
</style>
